<template>
    <div>
        <van-nav-bar
            title="标题"
            left-text="返回"
            left-arrow
            @click-left="onBack"
        />
        <van-cell-group>
            <van-field
                    v-model="password"
                    type="password"
                    required
                    clearable
                    label="旧密码"
                    placeholder="请输入旧密码"
            />
            <van-field
                    v-model="newPassword"
                    type="password"
                    label="新密码"
                    placeholder="请输入新密码"
                    required
            />
            <van-button type="primary" size="large" @click="passReset">修改</van-button>
        </van-cell-group>
    </div>
</template>
<script>
  import { passReset } from '@/api'
  import { Field, Button, Toast, Cell, CellGroup, NavBar } from 'vant'

  export default {
    components: {
      [Field.name]: Field,
      [Cell.name]: Cell,
      [CellGroup.name]: CellGroup,
      [NavBar.name]: NavBar,
      [Button.name]: Button
    },
    data () {
      return {
        password: '', // 员工编号
        newPassword: ''
      }
    },
    methods: {
      passReset () {
        let data = {ygbh: this.ygbh, mm: this.password}
        passReset(data).then((res) => {
          if (res.status === 200) {
            Toast('修改成功')
          }
        })
      },
      onBack () {
        this.$router.back()
      }
    }
  }
</script>
